home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Languages / MS Cobol4.5 / DEMO / DECLARE.CBL < prev    next >
Text File  |  1991-04-08  |  2KB  |  56 lines

  1.       $set ans85 mf noosvs
  2.       ************************************************************
  3.       *                                                          *
  4.       *              (C) Micro Focus Ltd. 1989                   *
  5.       *                                                          *
  6.       *                     DECLARE.CBL                          *
  7.       *                                                          *
  8.       *    This program demonstrates how to use declaratives.    *
  9.       *                                                          *
  10.       ************************************************************
  11.  
  12.        select input-file   assign to file-name
  13.                            organization sequential
  14.                            file status is file-stat.
  15.  
  16.        data division.
  17.        file section.
  18.  
  19.        fd  input-file.
  20.        01  input-rec       pic x(80).
  21.  
  22.        working-storage section.
  23.        01  file-stat.
  24.            03  f-stat-1    pic x.
  25.            03  f-stat-2    pic x.
  26.            03  f-stat-2-bin redefines f-stat-2
  27.                            pic 9(2) comp-x.
  28.        01  stat-disp.
  29.            03  disp1       pic x.
  30.            03  filler      pic x.
  31.            03  disp2       pic 9(3).
  32.  
  33.        procedure division.
  34.        declaratives.
  35.        dec-laratives section.
  36.        use after standard error procedure on input-file.
  37.            move f-stat-1 to disp1
  38.            if f-stat-1 = "9"
  39.                move f-stat-2-bin to disp2
  40.            else
  41.                move f-stat-2 to disp2
  42.            end-if
  43.            display "file status :" at 1029
  44.            display stat-disp       at 1049
  45.            stop run.
  46.        end declaratives.
  47.  
  48.        main section.
  49.        sta-rt.
  50.            display spaces upon crt
  51.            display "enter a non-existant file name :" at 0810
  52.            accept file-name at 0849
  53.            open input input-file
  54.            display "Open worked. Try a different filename."
  55.            stop run.
  56.